

def convertToPairs(fin,fout):
    f=open(fin)
    
    data=f.readlines()
    f.close()
    head=data[0][:-1]
    data=data[1:]
    head=head.split(",")[2:]
    
    f=open(fout,"w")
    
    for l in data:
        d=l[:-1].split(",")
        rt=d[1]
        d=d[2:]
        for i in range(len(d)):
            f.write("%s,H/%s, %s\n"%(rt,head[i],d[i]))
            
    f.close()


convertToPairs("situation_hazard_table.csv","situation_hazard_pairs.csv")
convertToPairs("hazard_action_table.csv","hazard_action_pairs.csv")
               
        

    

    
